<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-project-edit" th:object="${project}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">项目简介：</label>
				<div class="col-sm-8">
					<input id="brief" name="brief" th:field="*{brief}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="${project.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">项目状态，0正常，1删除：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="status" name="status" th:field="*{status}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">创建者：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="createBy" name="createBy" th:field="*{createBy}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">创建时间：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="createTime" name="createTime" th:field="*{createTime}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">更新者：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="updateBy" name="updateBy" th:field="*{updateBy}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
			<!--<div class="form-group">	-->
				<!--<label class="col-sm-3 control-label">更新时间：</label>-->
				<!--<div class="col-sm-8">-->
					<!--<input id="updateTime" name="updateTime" th:field="*{updateTime}" class="form-control" type="text">-->
				<!--</div>-->
			<!--</div>-->
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "project/project"
		$("#form-project-edit").validate({
			rules:{
                name:{
					required:true,
				},
				status:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            edit();
	            // $.operate.save(prefix + "/edit", $('#form-project-edit').serialize());
	        }
	    }

        function edit() {
            var id = $("input[name='id']").val();
            var name = $("input[name='name']").val();
            var brief = $("input[name='brief']").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/edit",
                data : {
                    "id":id,
                    "name": name,
                    "brief": brief,
                    "status": status
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
</body>
</html>
